<template>
  <h1>表格组件</h1>
  <el-table :data="tableData" style="width: 50%;margin: 0 auto">
    <el-table-column prop="date" label="Date" width="180" align="center"/>
    <el-table-column prop="name" label="Name" width="180"/>
    <el-table-column prop="address" label="Address"/>
  </el-table>
  <el-table :data="arr" style="width: 70%;margin: 0 auto">
      <el-table-column type="index" label="序号" width="80" align="center"/>
      <el-table-column prop="name" label="姓名" align="center"/>
      <el-table-column prop="salary" label="工资" align="center"/>
      <el-table-column prop="job" label="职位"  align="center"/>
    <el-table-column label="操作"  align="center">
      <template #default="scope">
        <el-button type="danger" @click="del(scope.row,scope.$index)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>


</template>

<script setup>

import {ref} from "vue";

const arr = ref([
  {name:'张三',salary:'3000',job:'护工'},
  {name:'张四',salary:'4000',job:'护士'},
  {name:'张五',salary:'5000',job:'护士长'},
  {name:'张六',salary:'6000',job:'科长'},
]);
const del = (emp,index)=>{
  if (confirm('确定删除'+emp.name+'吗？')){
    arr.value.splice(index,1);
  }
}
const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
</script>

<style scoped>
</style>